package cn.zkrt.iotms.module.iot.controller;

import cn.zkrt.iotms.comm.R;
import cn.zkrt.iotms.module.iot.dto.DeviceBPageDto;
import cn.zkrt.iotms.module.iot.service.DeviceBService;
import cn.zkrt.iotms.module.iot.vo.BindingDeviceVO;
import cn.zkrt.iotms.module.iot.vo.DeviceBPageVO;
import cn.zkrt.iotms.module.iot.vo.DeviceCategoryTotalVO;
import cn.zkrt.iotms.module.iot.vo.UnbindDeviceVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: xulinyu
 * date:  2024/10/14 15:10
 */
@RestController
@RequestMapping("deviceB")
@Api(tags = "7增殖站-设施管理")
public class SFSDeviceBController {


    private final DeviceBService deviceBService;

    public SFSDeviceBController(DeviceBService deviceBService) {
        this.deviceBService = deviceBService;
    }

    @ApiOperation("车间、鱼池、设备分页查询")
    @GetMapping("page")
    public R<Page<DeviceBPageVO>> page(Page<DeviceBPageVO> page, DeviceBPageDto dto){
        return R.data(deviceBService.sfsPage(page,dto));
    }



    @ApiOperation("车间、鱼池、设备数量")
    @GetMapping("total")
    public R<DeviceCategoryTotalVO> categoryTotal(@RequestParam("stcd") String stcd){
        return R.data(deviceBService.categoryTotal(stcd));
    }




    @ApiOperation("车间、鱼池、设备动态绑定")
    @GetMapping("dynamicBinding")
    public R<Boolean> dynamicBinding(@RequestParam("deviceId")String deviceId,@RequestParam("parentId")String parentId){
        return R.data(deviceBService.dynamicBinding(deviceId,parentId));
    }


    @ApiOperation("查询未绑定的设备列表")
    @GetMapping("unbind/list")
    public R<List<UnbindDeviceVO>> unbindList(@RequestParam("stcd") String stcd){
        return R.data(deviceBService.unbindList(stcd));
    }



    @ApiOperation("车间、鱼池、设备解除绑定")
    @GetMapping("unbind")
    public R<Boolean> unbind(@RequestParam("deviceId")String deviceId){
        return R.data(deviceBService.unbind(deviceId));
    }


    @ApiOperation("查询绑定关系图")
    @GetMapping("binding/list")
    public R<BindingDeviceVO> bindingList(@RequestParam("stcd")String stcd){
        return R.data(deviceBService.bindingList(stcd));
    }


}
